/*
 ============================================================================
 Name		: LlcpReceiveHandler.h
 Author	  : 
 Version	 : 1.0
 Copyright   : 
 Description : CLlcpReceiveHandler declaration
 ============================================================================
 */

#ifndef LLCPRECEIVEHANDLER_H
#define LLCPRECEIVEHANDLER_H

#include <e32base.h>	// For CActive, link against: euser.lib

class MP2PMessageSupplier;
class MLlcpConnOrientedTransporter;


class CLlcpReceiveHandler : public CActive
	{
public:
	// Cancel and destroy
	~CLlcpReceiveHandler();

	// Two-phased constructor.
	static CLlcpReceiveHandler* NewL(MLlcpConnOrientedTransporter* aTransporter,
			MP2PMessageSupplier* aMessageSupplier);

	// Two-phased constructor.
	static CLlcpReceiveHandler* NewLC(MLlcpConnOrientedTransporter* aTransporter,
			MP2PMessageSupplier* aMessageSupplier);

private:
	// C++ constructor
	CLlcpReceiveHandler(MLlcpConnOrientedTransporter* aTransporter,
			MP2PMessageSupplier* aMessageSupplier);

	// Second-phase constructor
	void ConstructL();

private:
	// From CActive
	// Handle completion
	void RunL();

	// How to cancel me
	void DoCancel();

	// Override to handle leaves from RunL(). Default implementation causes
	// the active scheduler to panic.
	TInt RunError(TInt aError);
	
	TInt StartReceive();

private:
	enum TState
		{
		EConnected,
		EReceiving,
		EError
		// Error condition
		};

private:
	TInt iState; // State of the active object

	RBuf8 iReceiveBuf;
	MLlcpConnOrientedTransporter* iTransporter;
	MP2PMessageSupplier* iMessageSupplier;

	};

#endif // LLCPRECEIVEHANDLER_H
